package leo.weixin.entity.menu;


import lombok.Data;


import java.util.List;

/**
 * 带事件的菜单(包括 普通点击 , 素材请求, 素材上传 , 位置 , 调用硬件   )
 *  "type": "scancode_push",  //必须
 *  "name": "扫码推事件",    //必须
 *  "key": "rselfmenu_0_1",  //必须
 *  "sub_button": [ ]    //非必须
 */
@Data
public class EventButton extends SubButton {
    private String key ;  //事件码

    private EventButton(String name, String key, String type) {
        super(name);
        setType(type);
        this.key = key ;
    }

    public static EventButton createByNameKeyType(String name, String key, String type){
        return new EventButton(name, key, type);
    }

    /**
     * 普通点击按钮
     * @param name 显示的名字
     * @param key 绑定的key值
     * @return
     */
    public static EventButton createClickButton(String name, String key){
        return createByNameKeyTypeWithSubButton(name,key,ButtonTypeEnum.CLICK,null);
    }

    /**
     * 带事件的位置选择按钮
     * @param name 显示的名字
     * @param key 绑定的key值
     * @return
     */
    public static EventButton createLocationButton(String name, String key){
        return createByNameKeyTypeWithSubButton(name,key,EventButtonType.LOCATION_SELECT,null);
    }


    public static EventButton createByNameKeyTypeWithSubButton(String name, String key, String type, List<AbstractButton> sub_button){
        return (EventButton) createByNameKeyType(name, key, type).setSub_button(sub_button);
    }

    public interface  EventButtonType{
        String SCANCODE_PUSH = "scancode_push";
        String SCANCODE_WAITMSG = "scancode_waitmsg";
        String PIC_SYSPHOTO = "pic_sysphoto";
        String PIC_PHOTO_OR_ALBUM = "pic_photo_or_album";
        String PIC_WEIXIN = "pic_weixin";
        String LOCATION_SELECT = "location_select";
    }
}
